﻿$(function(){//延迟加载
	var departmentId=$('#departmentId').val();
	$.ajax({
		url:'getdproles?departmentId='+departmentId,
		success:function(data){
			$('#dprole').combobox('setValues',data);
		}
	});
	
	$('#comeditdepartment').click(function(){
		if(!$('#st1').form('validate')){
			return
		}
		var dproles='';
		var str = $('#dprole').combobox('getValues');
		for(var i=0;i<str.length;i++){
			dproles=dproles+str[i]+',';
		}
		dproles=dproles.substring(0,dproles.length-1);
		var dpname=$('#dpname').val();
		var dptel=$('#dptel').val();
		var dploc=$('#dploc').val();
		var dpleader=$('#dpleader').combobox('getValue');
		$.ajax({
			url:'editdepartment',
			method:'POST',
			data:{
				departmentId:departmentId,
				dpname:dpname,
				dptel:dptel,
				dploc:dploc,
				dproles:dproles,
				dpleader:dpleader
			},
			success:function(data){
				alert(data.msg);
				parent.addTab('编辑部门信息','toeditdepartment?departmentId='+departmentId);
			}
		});
		
	});
	
});